package Day48.day26;

import java.util.Scanner;

public class t2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        int[] dpMax = new int[n];
        for(int i = 0;i < n;i++){
            array[i] = sc.nextInt();
        }
        if(n == 1) {
            System.out.println(array[0]);
            return;
        }
        dpMax[0] = array[0];
        dpMax[1] = Math.max(array[0], array[1]);
        for(int i = 2;i < n;i++){
            dpMax[i] = Math.max(dpMax[i - 2] + array[i], dpMax[i - 1]);
        }
        System.out.println(dpMax[n - 1]);
    }
}
